package com.hz.wjy.mapper;

import com.hz.wjy.model.entiy.UserEntiy;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper {

    @Insert("insert into users values (null, #{username}, #{realname}, #{student_id}, #{pwd_salt}, #{pwd}, #{pwd_valid_date}, #{user_type}, #{pwd_error_count}, #{class_id}, #{grade_id})")
    public void addUser(UserEntiy userEntiy);

    @Select("SELECT * FROM users;")
    public List<UserEntiy> findAll();


    @Delete("DELETE FROM users WHERE id = #{id};")
    public void deleteUser(int id);


    @Select("SELECT * FROM users WHERE username = #{username}")
    public UserEntiy findUserByUsername(@Param("username") String username);


}
